<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>计数器</title>
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}

			#input-num {
				height: 20px;
				text-align: center;
				margin-top: 100px;
				margin-left: 700px;
			}

			#button1,
			#butten2 {
				width: 20px;
				height: 20px;
			}

			#button1 {
				float: left;
			}

			#butten2 {
				float: left;
			}

			span {
				float: left;
				width: 70px;
				height: 20px;
				background: #00AAFF;
			}
		</style>
	</head>
	<body>
		<div id="input-num">
			<button type="button" id="button1" @click="sub()">-</button>
			<span>{{ num }}</span>
			<button type="button" id="butten2" @click="add()">+</button>
		</div>
		<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
		<script type="text/javascript">
			var app = new Vue({
				el: "#input-num",
				data: {
					num: 0
				},
				methods: {
					add: function() {
						if (this.num < 10) {
							this.num++;
						} else {
							alert("别点了,满了！")
						}
					},
					sub: function() {
						if (this.num > 0) {
							this.num--;
						} else {
							alert("别点了,没了！")
						}

					}
				}
			})
		</script>
	</body>
</html>
